const router = require('koa-router')()
const { pubsub, SUB_ADD } = require('../resolvers')

router.get('/', async (ctx, next) => {
  const message = `发送随机字符串: [ ${Date.now()} ] `
  pubsub.publish(SUB_ADD, { subAdd: { message } })
  await ctx.render('index', {
    title: message
  })
})

module.exports = router
